<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="gv-forms" layout="column">
  <h1>Transfer ownership</h1>

  <div class="gv-form">
    <h2></h2>
    <div class="gv-form-content" layout="column"  layout-align="start stretch">
      <div ng-if="apiTransferOwnershipCtrl.isAllowedToTransferOwnership()">
        <p>
          Give full access to this API to an other user.
        </p>
        <md-autocomplete
                md-search-text="searchText"
                md-selected-item-change="apiTransferOwnershipCtrl.selectedUserChange(user)"
                md-items="user in apiTransferOwnershipCtrl.searchUser(searchText)"
                md-item-text="user.displayName"
                placeholder="Select a user"
                md-autofocus="false"
                md-delay="500"
                md-min-length="0"
                md-menu-class="autocomplete-custom-template">
          <md-item-template>
            <md-list-item class="md-2-line contact-item">
              <div class="md-list-item-text compact">
                <span style="font-size: medium;">{{user.displayName}}</span>
                <span style="padding-left: 24px; font-size: small;" ng-if="user.email">{{user.email}}</span>
              </div>
            </md-list-item>
          </md-item-template>
          <md-not-found>
            No user matching "{{searchText}}" were found.
          </md-not-found>
        </md-autocomplete>
        <br/>
        <md-input-container class="md-block">
          <label>New role for current Primary Owner</label>
          <md-select ng-model="apiTransferOwnershipCtrl.newPORole">
            <md-option ng-value="role" ng-repeat="role in apiTransferOwnershipCtrl.newPORoles">{{role.name}}</md-option>
          </md-select>
        </md-input-container>

        <div class="md-actions gravitee-api-save-button" layout="row">
          <md-button ng-disabled="apiTransferOwnershipCtrl.newPrimaryOwner == null" class="md-primary md-raised" ng-click="apiTransferOwnershipCtrl.showTransferOwnershipConfirm($event)">Transfer</md-button>
        </div>

      </div>
    </div>
  </div>
</div>
